home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / codecs / qdmediahandler / qdrawhandler.c < prev    next >
Encoding:
Text File  |  2000-06-23  |  18.6 KB  |  649 lines

  1. //////////
  2. //
  3. //    File:        QDrawHandler.c
  4. //
  5. //    Contains:    Code for creating a derived media handler component for QuickDraw pictures.
  6. //
  7. //    Written by:    Tim Monroe
  8. //                Based on MyMediaComponent by John Wang (see develop issue 14), with some
  9. //                assistance from SampleMediaHandler by deeje cooley.
  10. //
  11. //    Copyright:    © 1993-1999 by Apple Computer, Inc., all rights reserved.
  12. //
  13. //    Change History (most recent first):
  14. //
  15. //       <7>         02/25/99    rtm        added some comments
  16. //       <6>         01/28/99    rtm        fixed bug that caused garbage to be drawn when Copy menu item selected
  17. //                                    or a drag of movie clipping attempted
  18. //       <5>         01/25/99    rtm        got Windows DLL working
  19. //       <4>         01/21/99    rtm        got both MacOS PPC and 68K versions working
  20. //       <3>         01/15/99    rtm        coordinated with SampleMediaHandler by deeje cooley
  21. //       <2>         01/05/99    rtm        revised coding style
  22. //       <1>         02/25/93    jw        first file; based on MyComponent shell
  23. //
  24. //    This project builds a derived (or custom) media handler. See the chapter "Derived Media Handler
  25. //    Components" in the book Inside Macintosh: QuickTime Components for information about writing
  26. //    derived media handler components. See also John Wang's article on derived media handlers in develop,
  27. //    issue 14, for more information about the QuickDraw media handler. The main difference between his
  28. //    code and the current sample code is that I've made the dispatching routines both PPC- and Windows-savvy,
  29. //    using the ComponentDispatchHelper code. Also fixed a few bugs and added some more comments.
  30. //
  31. //////////
  32.  
  33.  
  34. //////////
  35. //
  36. // header files
  37. //
  38. //////////
  39.  
  40. #include "QDrawHandler.h"
  41.  
  42.  
  43. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. //
  45. // Component dispatch helper defines
  46. //
  47. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  48.  
  49. #if TARGET_CPU_68K
  50.     #define COMPONENT_C_DISPATCHER
  51.     #define COMPONENT_DISPATCH_MAIN
  52. #endif
  53.  
  54. #define MEDIA_BASENAME()                 QDMH_
  55. #define MEDIA_GLOBALS()                 QDMH_GlobalsHdl storage
  56.  
  57. #define CALLCOMPONENT_BASENAME()        MEDIA_BASENAME()
  58. #define    CALLCOMPONENT_GLOBALS()            MEDIA_GLOBALS()
  59.  
  60. #define COMPONENT_UPP_PREFIX()            uppMedia
  61. #define COMPONENT_SELECT_PREFIX()          kMedia
  62. #define COMPONENT_DISPATCH_FILE            "QDrawHandlerDispatch.h"
  63.  
  64. #define    GET_DELEGATE_COMPONENT()        ((**storage).fDelegate)
  65.  
  66. #include "Components.k.h"
  67. #include "MediaHandlers.k.h"
  68. #include "ComponentDispatchHelper.c"
  69.  
  70.  
  71. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  72. //
  73. // Required component calls
  74. //
  75. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  76.  
  77. //////////
  78. //
  79. // QDMH_Open
  80. // Open the derived media handler component.
  81. //
  82. //////////
  83.  
  84. PASCAL_RTN ComponentResult QDMH_Open (QDMH_GlobalsHdl storage, ComponentInstance theSelf)
  85. {
  86. #pragma unused(storage)
  87.  
  88.     QDMH_GlobalsHdl                myStorage = NULL;
  89.     ComponentInstance            myComponent = NULL;
  90.     
  91.     // allocate the private global storage used by this component instance
  92.     myStorage = (QDMH_GlobalsHdl)NewHandleClear(sizeof(QDMH_Globals));    
  93.     if (myStorage == NULL)
  94.         return(MemError());
  95.     
  96.     SetComponentInstanceStorage(theSelf, (Handle)myStorage);
  97.     
  98.     // open the base media handler component and target it
  99.     myComponent = OpenDefaultComponent(MediaHandlerType, BaseMediaType);    
  100.     if (myComponent == NULL)
  101.         return(componentNotCaptured);
  102.     
  103.     ComponentSetTarget(myComponent, theSelf);
  104.  
  105.     (**myStorage).fDelegate = myComponent;
  106.     (**myStorage).fSelf = theSelf;
  107.     (**myStorage).fParent = theSelf;
  108.  
  109.     return(noErr);
  110. }
  111.  
  112.  
  113. //////////
  114. //
  115. // QDMH_Close
  116. // Close the derived media handler component.
  117. //
  118. //////////
  119.  
  120. PASCAL_RTN ComponentResult QDMH_Close (QDMH_GlobalsHdl storage, ComponentInstance theSelf)
  121. {
  122. #pragma unused(theSelf)
  123.  
  124.     if (storage != NULL) {
  125.  
  126.         // close the base media handler component instance
  127.         if ((**storage).fDelegate != NULL)
  128.             CloseComponent((**storage).fDelegate);
  129.         
  130.         // dispose of the private global storage created by the _Open routine
  131.         DisposeHandle((Handle)storage);
  132.     }
  133.     
  134.     return(noErr);
  135. }
  136.  
  137.  
  138. //////////
  139. //
  140. // QDMH_Version
  141. // Return the version of the derived media handler component.
  142. //
  143. //////////
  144.  
  145. PASCAL_RTN ComponentResult QDMH_Version (QDMH_GlobalsHdl storage)
  146. {
  147. #pragma unused(storage)
  148.  
  149.     return(kQDMH_Version);
  150. }
  151.  
  152.  
  153. //////////
  154. //
  155. // QDMH_Register
  156. // Register.
  157. //
  158. // This routine is called once (usually at boot time) when the Component Manager first
  159. // registers this component. Note that the cmpWantsRegisterMessage bit must be set in
  160. // the component flags of the component in order for this routine to be called.
  161. //
  162. //////////
  163.  
  164. PASCAL_RTN ComponentResult QDMH_Register (QDMH_GlobalsHdl storage)
  165. {
  166.     if (storage != NULL)
  167.         return(noErr);    // globals properly set up: the base media handler was targeted OK
  168.     else
  169.         return(-1);        // globals not properly set up: don't register
  170. }
  171.  
  172.  
  173. //////////
  174. //
  175. // QDMH_Target
  176. // Target.
  177. //
  178. //////////
  179.  
  180. PASCAL_RTN ComponentResult QDMH_Target (QDMH_GlobalsHdl storage, ComponentInstance theTarget)
  181. {
  182.     // remember who is at the top of our calling chain
  183.     (**storage).fParent = theTarget;
  184.     
  185.     // inform the base media handler of the change
  186.     ComponentSetTarget((**storage).fDelegate, theTarget);
  187.     
  188.     return(noErr);
  189. }
  190.  
  191.  
  192. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  193. //
  194. // Derived media handler functions
  195. //
  196. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  197.  
  198. //////////
  199. //
  200. // QDMH_Initialize
  201. // Initialize our media handler.
  202. //
  203. //////////
  204.  
  205. PASCAL_RTN ComponentResult QDMH_Initialize (QDMH_GlobalsHdl storage, GetMovieCompleteParams *theGMC)
  206. {
  207.     ComponentResult            myErr = noErr;
  208.     long                    myFlags;
  209.  
  210.     if ((storage == NULL) || (theGMC == NULL))
  211.         return(paramErr);
  212.         
  213.     // set general characteristics
  214.     (**storage).fMovie = theGMC->theMovie;
  215.     (**storage).fTrack = theGMC->theTrack;
  216.     (**storage).fMedia = theGMC->theMedia;
  217.     (**storage).fCurMediaRate = theGMC->effectiveRate;
  218.     MacSetRect(&((**storage).fGraphicsBox), 0, 0, (short)(theGMC->width >> 16), (short)(theGMC->height >> 16));
  219.     (**storage).fTrackMatrix = theGMC->trackMovieMatrix;
  220.     (**storage).fPort = theGMC->moviePort;
  221.     (**storage).fDevice = theGMC->movieGD;
  222.     (**storage).fSampleDescIndex = -1;
  223.  
  224.     // set media globals
  225.     (**storage).fWhatChanged = kQDMHAllChanged;
  226.     (**storage).fEnabled = false;
  227.     (**storage).fNewMediaRate = theGMC->effectiveRate;
  228.     (**storage).fPrevMediaTime = -1;
  229.     
  230.     // inform the base media handler of our capabilities:
  231.     // * handlerHasSpatial indicates that we draw
  232.     // * handlerNeedsBuffer indicates that we want QuickTime to maintain a drawing buffer for us
  233.     myFlags = handlerHasSpatial | handlerNeedsBuffer;
  234.     myErr = MediaSetHandlerCapabilities((**storage).fDelegate, myFlags, -1);
  235.  
  236.     return(myErr);
  237. }
  238.  
  239.  
  240. //////////
  241. //
  242. // QDMH_Idle
  243. // Draw our media sample.
  244. //
  245. // Here is where we get time to process the current media sample data. In our case, we want to extract
  246. // the QuickDraw picture data from the media and draw it into the current graphics port. If the sample
  247. // data consisted of a complete QuickDraw picture, we could get that picture by calling GetMediaSample
  248. // and then draw the picture by calling MacSetRect, TransformRect, and DrawPicture. (This is the route
  249. // taken in the derived media handler described in Inside Macintosh: QuickTime Components, pp. 10-9 to
  250. // 10-14.) Our media handler, however, supports key frames (also called sync frames), which complicate
  251. // the work we need to do here. A key frame is a sample that does not rely on previous samples for any 
  252. // of its information. A non-key frame (or difference frame) contains just data that has changed from
  253. // the previous frame. 
  254. //
  255. //////////
  256.  
  257. PASCAL_RTN ComponentResult QDMH_Idle (QDMH_GlobalsHdl storage, TimeValue theMediaTime, long theFlagsIn, long *theFlagsOut, const TimeRecord *theMovieTime)
  258. {
  259. #pragma unused(theMovieTime)
  260.  
  261.     Media                myMedia = (**storage).fMedia;
  262.     TimeValue            myPrevMediaTime = (**storage).fPrevMediaTime;
  263.     long                myWhatChanged;            // flags indicating changes in media environment
  264.     GDHandle            mySavedGD;
  265.     CGrafPtr            mySavedPort;
  266.     Rect                myDrawRect;
  267.     Boolean                myRedraw;                // do we need to draw anything?
  268.     Boolean                myIsDone;
  269.     TimeValue            myTime;
  270.     long                mySize;
  271.     PicHandle            mySyncPic = NULL;
  272.     PicHandle            myCurrPic = NULL;
  273.     TimeValue            mySyncSampleTime;
  274.     TimeValue            myCurrSampleTime;
  275.     long                myCurrSampleIndex;
  276.     OSErr                myErr = noErr;
  277.  
  278.     //////////
  279.     //
  280.     // inspect theFlagsIn to determine what the Movie Toolbox wants us to do
  281.     //
  282.     //////////
  283.  
  284.     // don't draw anything if mPreflightDraw flag is set
  285.     if (theFlagsIn & mPreflightDraw)
  286.         return(myErr);
  287.  
  288.     //////////
  289.     //
  290.     // initialize
  291.     //
  292.     //////////
  293.  
  294.     // allocate space for two pictures (the current sample's picture and the previous sync frame);
  295.     // GetMediaSample resizes these handles as necessary when returning the media data
  296.     mySyncPic = (PicHandle)NewHandle(sizeof(Picture));
  297.     myCurrPic = (PicHandle)NewHandle(sizeof(Picture));
  298.     if ((mySyncPic == NULL) || (myCurrPic == NULL)) {
  299.         myErr = memFullErr;
  300.         goto bail;
  301.     }
  302.     
  303.     GetGWorld(&mySavedPort, &mySavedGD);
  304.     SetGWorld((GWorldPtr)(**storage).fPort, (**storage).fDevice);
  305.     
  306.     //////////
  307.     //
  308.     // get information about the current sample
  309.     //
  310.     //////////
  311.  
  312.     myErr = GetMediaSample(myMedia, (Handle)myCurrPic, 0, NULL, theMediaTime, &myCurrSampleTime, NULL, NULL, &myCurrSampleIndex, 0, NULL, NULL);
  313.     if (myErr != noErr)
  314.         goto bail;
  315.     
  316.     // check to see whether the sample description index has changed since the last sample
  317.     if (myCurrSampleIndex != (**storage).fSampleDescIndex) {
  318.         (**storage).fSampleDescIndex = myCurrSampleIndex;
  319.         (**storage).fWhatChanged |= kQDMHSampleDescChanged;
  320.     }
  321.  
  322.     //////////
  323.     //
  324.     // determine what, if anything, in the media has changed
  325.     // (we don't need to draw the current media sample if nothing has changed)
  326.     //
  327.     //////////
  328.  
  329.     myRedraw = false;
  330.     myWhatChanged = (**storage).fWhatChanged;
  331.     
  332.     if (myWhatChanged != kQDMHNothingChanged) {
  333.  
  334.         if (myWhatChanged & kQDMHSetActive)        // if media was just enabled, then redraw; else don't change
  335.             myRedraw = (**storage).fEnabled;
  336.  
  337.         if (myWhatChanged & kQDMHSetRate) {
  338.             // if we are now playing in the opposite direction, then redraw
  339.             if ((((**storage).fCurMediaRate < 0) && ((**storage).fNewMediaRate > 0))
  340.              || (((**storage).fCurMediaRate > 0) && ((**storage).fNewMediaRate < 0)))
  341.                 myRedraw = true;
  342.             (**storage).fCurMediaRate = (**storage).fNewMediaRate;
  343.         }
  344.         
  345.         if (myWhatChanged & kQDMHTrackEdited)
  346.             myRedraw = true;                    // if track edited, then redraw
  347.         
  348.         if (myWhatChanged & kQDMHSetGWorld)
  349.             myRedraw = true;                    // if new GWorld, then redraw
  350.         
  351.         if (myWhatChanged & kQDMHSetDimensions)
  352.             myRedraw = true;                    // if new dimensions, then redraw
  353.         
  354.         if (myWhatChanged & kQDMHSetMatrix)
  355.             myRedraw = true;                    // if new matrix, then redraw
  356.         
  357.         if (myWhatChanged & kQDMHSampleDescChanged) {
  358.             QDrawDescriptionHandle        myQDDesc;
  359.             
  360.             // the sample description has changed; make sure it's a version we can handle
  361.             myQDDesc = (QDrawDescriptionHandle)NewHandleClear(sizeof(QDrawDescription));
  362.             if (myQDDesc != NULL) {
  363.                 GetMediaSampleDescription(myMedia, (**storage).fSampleDescIndex, (SampleDescriptionHandle)myQDDesc);
  364. #if HANDLER_SWAPS_SAMPLE_DESC
  365.                 if ((**myQDDesc).version > kQDMH_Version)
  366. #else
  367.                 if ((**myQDDesc).version > EndianU32_NtoB(kQDMH_Version))
  368. #endif
  369.                     (**storage).fEnabled = false;
  370.                 DisposeHandle((Handle)myQDDesc);
  371.             } else {
  372.                 (**storage).fEnabled = false; 
  373.             }
  374.         }
  375.         
  376.         // clear out flags indicating changes in media environment
  377.         (**storage).fWhatChanged = kQDMHNothingChanged;
  378.     }
  379.     
  380.     // if we are playing the movie backwards, we must always redraw from last sync frame
  381.     if ((**storage).fCurMediaRate < 0)
  382.         myRedraw = true;
  383.     
  384.     //////////
  385.     //
  386.     // we do not need to draw anything if myRedraw is false and if myPrevMediaTime == myCurrSampleTime
  387.     // (since we've already drawn that sample and nothing has occurred to cause us to have to redraw it)
  388.     //
  389.     // otherwise, we do need to draw; what we draw depends on the value of myRedraw:
  390.     //  (a) if myRedraw = true, redraw everything since the previous key frame
  391.     //    (b) if myRedraw = false, redraw everything since the previous key frame or the previous media frame,
  392.     //        whichever is closer to current frame
  393.     //
  394.     //////////
  395.  
  396.     if (myRedraw || (myPrevMediaTime != myCurrSampleTime)) {
  397.     
  398.         // find the previous key frame; note that we use the nextTimeEdgeOK flag, since the current frame
  399.         // might be a key frame; note also that if the media doesn't contain any key frames, the sample
  400.         // time returned in mySyncSampleTime is the same as myCurrSampleTime (that is, every frame is a key
  401.         // frame)
  402.         
  403.         GetMediaNextInterestingTime(myMedia, nextTimeSyncSample + nextTimeEdgeOK, myCurrSampleTime, -1, &mySyncSampleTime, NULL);
  404.         
  405.         // if myRedraw = false, mySyncSampleTime <= myPrevMediaTime, and myCurrSampleTime is ahead of
  406.         // myPrevMediaTime, then search to set the place to draw as the sample after myPrevMediaTime
  407.         if (!myRedraw && (mySyncSampleTime <= myPrevMediaTime) && (myPrevMediaTime < myCurrSampleTime)) {
  408.             myTime = mySyncSampleTime;
  409.             
  410.             while ((myTime >= 0) && (myTime < myPrevMediaTime))
  411.                 GetMediaNextInterestingTime(myMedia, nextTimeMediaSample, myTime, 1, &myTime, NULL);
  412.  
  413.             if ((myTime == myPrevMediaTime) && (myTime != -1)) {
  414.                 GetMediaNextInterestingTime(myMedia, nextTimeMediaSample, myTime, 1, &myTime, NULL);
  415.                 if (myTime != -1)
  416.                     mySyncSampleTime = myTime;    
  417.             }
  418.         }
  419.         
  420.     //////////
  421.     //
  422.     // draw the picture, beginning at mySyncSampleTime; but don't draw if the media is disabled
  423.     //
  424.     //////////
  425.  
  426.         myIsDone = false;
  427.         myTime = mySyncSampleTime;
  428.         while (!myIsDone && (**storage).fEnabled) {
  429.         
  430.             if (myTime == myCurrSampleTime)
  431.                 myIsDone = true;
  432.                 
  433.             myErr = GetMediaSample(myMedia, (Handle)mySyncPic, 0, &mySize, myTime, NULL, NULL, NULL, NULL, 0, NULL, NULL);
  434.             if (myErr != noErr)
  435.                 goto bail;
  436.                 
  437.             myDrawRect = (**storage).fGraphicsBox;
  438.             TransformRect(&(**storage).fTrackMatrix, &myDrawRect, NULL);
  439.             DrawPicture(mySyncPic, &myDrawRect);
  440.             if (!myIsDone) {
  441.                 GetMediaNextInterestingTime(myMedia, nextTimeMediaSample, myTime, 1, &myTime, NULL);
  442.                 if (myTime < 0)
  443.                     myIsDone = true;
  444.             }
  445.         }
  446.         
  447.         // say we drew somthing
  448.         *theFlagsOut |= mDidDraw;
  449.     }
  450.     
  451.     // update the previous media time
  452.     (**storage).fPrevMediaTime = myCurrSampleTime;
  453.         
  454.     //////////
  455.     //
  456.     // clean up and return
  457.     //
  458.     //////////
  459.     
  460. bail:
  461.     SetGWorld((GWorldPtr)mySavedPort, mySavedGD);
  462.     
  463.     if (mySyncPic != NULL)
  464.         DisposeHandle((Handle)mySyncPic);
  465.     if (myCurrPic != NULL)
  466.         DisposeHandle((Handle)myCurrPic);
  467.     
  468.     return(myErr);
  469. }
  470.  
  471.  
  472. //////////
  473. //
  474. // QDMH_SetActive
  475. // Set the enabled state of the media.
  476. //
  477. //////////
  478.  
  479. PASCAL_RTN ComponentResult QDMH_SetActive (QDMH_GlobalsHdl storage, Boolean theEnableMedia)
  480. {
  481.     if ((**storage).fEnabled != theEnableMedia) {
  482.         (**storage).fEnabled = theEnableMedia;
  483.         (**storage).fWhatChanged |= kQDMHSetActive;
  484.     }
  485.     
  486.     return(noErr);
  487. }
  488.  
  489.  
  490. //////////
  491. //
  492. // QDMH_SetRate
  493. // Set the media rate.
  494. //
  495. //////////
  496.  
  497. PASCAL_RTN ComponentResult QDMH_SetRate (QDMH_GlobalsHdl storage, Fixed theRate)
  498. {
  499.     // save the new rate in fNewMediaRate so that we can compare with previous rate;
  500.     // if the new rate is in the same direction, we won't want to redraw again from the previous key frame
  501.     if ((**storage).fNewMediaRate != theRate) {
  502.         (**storage).fNewMediaRate = theRate;
  503.         (**storage).fWhatChanged |= kQDMHSetRate;
  504.     }
  505.     
  506.     return(noErr);
  507. }
  508.  
  509.  
  510. //////////
  511. //
  512. // QDMH_TrackEdited
  513. // Set the track-edited state.
  514. //
  515. //////////
  516.  
  517. PASCAL_RTN ComponentResult QDMH_TrackEdited (QDMH_GlobalsHdl storage)
  518. {
  519.     (**storage).fWhatChanged |= kQDMHTrackEdited;
  520.     
  521.     return(noErr);
  522. }
  523.  
  524.  
  525. //////////
  526. //
  527. // QDMH_SetGWorld
  528. // Set the media graphics port.
  529. //
  530. //////////
  531.  
  532. PASCAL_RTN ComponentResult QDMH_SetGWorld (QDMH_GlobalsHdl storage, CGrafPtr thePort, GDHandle theGD)
  533. {
  534.     (**storage).fPort = thePort;
  535.     (**storage).fDevice = theGD;
  536.     (**storage).fWhatChanged |= kQDMHSetGWorld;
  537.     
  538.     return(noErr);
  539. }
  540.  
  541.  
  542. //////////
  543. //
  544. // QDMH_SetDimensions
  545. // Set the media dimensions.
  546. //
  547. //////////
  548.  
  549. PASCAL_RTN ComponentResult QDMH_SetDimensions (QDMH_GlobalsHdl storage, Fixed theWidth, Fixed theHeight)
  550. {
  551.     MacSetRect(&((**storage).fGraphicsBox), 0, 0, (short)(theWidth >> 16), (short)(theHeight >> 16));
  552.     (**storage).fWhatChanged |= kQDMHSetDimensions;
  553.  
  554.     return(noErr);
  555. }
  556.  
  557.  
  558. //////////
  559. //
  560. // QDMH_SetMatrix
  561. // Set the track or movie matrix.
  562. //
  563. //////////
  564.  
  565. PASCAL_RTN ComponentResult QDMH_SetMatrix (QDMH_GlobalsHdl storage, MatrixRecord *theTrackMovieMatrix)
  566. {    
  567.     // don't cause unnecessary updates if the matrix doesn't really change
  568.     // (this can happen if the resize button is clicked on, but not moved)
  569.     if (!EqualMatrix(&((**storage).fTrackMatrix), theTrackMovieMatrix)) {
  570.         (**storage).fTrackMatrix = *theTrackMovieMatrix;
  571.         (**storage).fWhatChanged |= kQDMHSetMatrix;
  572.     }
  573.  
  574.     return(noErr);
  575. }
  576.  
  577.  
  578. //////////
  579. //
  580. // QDMH_SampleDescriptionChanged
  581. // Handle changes to the sample description tables.
  582. //
  583. //////////
  584.  
  585. PASCAL_RTN ComponentResult QDMH_SampleDescriptionChanged (QDMH_GlobalsHdl storage, long theIndex)
  586. {
  587.     // the sample description tables store info such as data version
  588.     (**storage).fSampleDescIndex = theIndex;
  589.     (**storage).fWhatChanged |= kQDMHSampleDescChanged;
  590.  
  591.     return(noErr);
  592. }
  593.  
  594.  
  595. #if HANDLER_SWAPS_SAMPLE_DESC
  596. //////////
  597. //
  598. // QDMH_SampleDescriptionB2N
  599. // Convert our sample description from big- to native-endian format.
  600. //
  601. //////////
  602.  
  603. PASCAL_RTN ComponentResult QDMH_SampleDescriptionB2N (QDMH_GlobalsHdl storage, SampleDescriptionHandle theSampleDesc)
  604. {
  605. #pragma unused(storage)
  606.  
  607.     QDrawDescriptionHandle        myQDDesc = (QDrawDescriptionHandle)theSampleDesc;
  608.     
  609.     if ((myQDDesc == NULL) || (*myQDDesc == NULL))
  610.         return(paramErr);
  611.  
  612. //    (**myQDDesc).size = EndianU32_BtoN((**myQDDesc).size);
  613. //    (**myQDDesc).type = EndianU32_BtoN((**myQDDesc).type);
  614. //    (**myQDDesc).resvd1 = EndianU32_BtoN((**myQDDesc).resvd1);
  615. //    (**myQDDesc).resvd2 = EndianU16_BtoN((**myQDDesc).resvd2);
  616. //    (**myQDDesc).dataRefIndex = EndianU16_BtoN((**myQDDesc).dataRefIndex);
  617.     (**myQDDesc).version = EndianU32_BtoN((**myQDDesc).version);
  618.     
  619.     return(noErr);
  620. }
  621.  
  622.  
  623. //////////
  624. //
  625. // QDMH_SampleDescriptionN2B
  626. // Convert our sample description from native- to big-endian format.
  627. //
  628. //////////
  629.  
  630. PASCAL_RTN ComponentResult QDMH_SampleDescriptionN2B (QDMH_GlobalsHdl storage, SampleDescriptionHandle theSampleDesc)
  631. {
  632. #pragma unused(storage)
  633.  
  634.     QDrawDescriptionHandle        myQDDesc = (QDrawDescriptionHandle)theSampleDesc;
  635.  
  636.     if ((myQDDesc == NULL) || (*myQDDesc == NULL))
  637.         return(paramErr);
  638.  
  639. //    (**myQDDesc).size = EndianU32_NtoB((**myQDDesc).size);
  640. //    (**myQDDesc).type = EndianU32_NtoB((**myQDDesc).type);
  641. //    (**myQDDesc).resvd1 = EndianU32_NtoB((**myQDDesc).resvd1);
  642. //    (**myQDDesc).resvd2 = EndianU16_NtoB((**myQDDesc).resvd2);
  643. //    (**myQDDesc).dataRefIndex = EndianU16_NtoB((**myQDDesc).dataRefIndex);
  644.     (**myQDDesc).version = EndianU32_NtoB((**myQDDesc).version);
  645.     
  646.     return(noErr);
  647. }
  648. #endif    // HANDLER_SWAPS_SAMPLE_DESC
  649.